import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:yysk_app/utils/colors.dart';
import 'package:yysk_app/utils/helper.dart';

class ListRouteTile extends StatelessWidget {
  final String title;
  final String? subtitle;
  final Widget? trailing;
  final String? route;
  final VoidCallback? onTap;
  final Widget? leading;
  const ListRouteTile({
    super.key,
    required this.title,
    this.subtitle,
    this.route,
    this.trailing,
    this.onTap,
    this.leading,
  });

  @override
  Widget build(BuildContext context) {
    return ListTile(
      leading: leading,
      minTileHeight: 30,
      onTap:
          onTap ??
          ((route != null && route!.isNotEmpty)
              ? () {
                Get.toNamed(route!);
              }
              : null),
      contentPadding: EdgeInsets.zero,
      title: Text(
        title,
        style: TextStyle(
          color: AppColors.fontColor,
          fontSize: 13.px,
        ),
      ),
      trailing:
          trailing ??
          Icon(
            Icons.arrow_forward_ios,
            color: AppColors.backgroundColorGrey,
            size: 13.px,
          ),
      subtitle: subtitle != null ? Text(subtitle!) : null,
    );
  }
}
